

package com.codeplex.boomships.Common;

import java.io.Serializable;

import javax.persistence.*;

/**
 *
 * @author fleischer
 */
@Entity
@Table(name = "players")
@NamedQueries({
	@NamedQuery(name = "Player.findByUserAndPass", query = "SELECT p FROM Player p WHERE p.plusername = :pUserName AND p.plpassword = :pPassword"),
	@NamedQuery(name = "Player.findById", query = "SELECT p FROM Player p WHERE p.plid = :pId"),
	@NamedQuery(name = "Player.findByUsername", query = "SELECT p FROM Player p WHERE p.plusername = :pUserName"),
})
public class Player implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id @GeneratedValue(strategy= GenerationType.SEQUENCE)
    @Column(name = "plid")
    private long id;
    
    @Column(name = "plusername")
    private String username;
    
    @Column(name = "plpassword")
    private String password;
    
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "plstat_id", unique=true, nullable=true, insertable=true, updatable=true)
    private PlayerStat playerStats;

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }
    
    /**
     * @return the username
     */
    public String getUsername() {
        return username;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }
    
    /**
     * @param username the username to set
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the playerStats
     */
    public PlayerStat getPlayerStats() {
        return playerStats;
    }

    /**
     * @param playerStats the playerStats to set
     */
    public void setPassword(PlayerStat playerStats) {
        this.playerStats = playerStats;
    }
   
    
    public Player(){}
    
    public Player(String pUserName, String pPass){
        this.username = pUserName;
        this.password = pPass;
    }
    
}
